/**********************************************************************
 * SailmiPIM - modular cross-platform feature Personal Information Manager Tools.
 * Copyright(C) 2006-2014  Georg Rudoy
 *
 * Distributed under the Boost Software License, Version 1.0.
 *(See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
 **********************************************************************/

#include "anutil.h"
#include <QString>
#include <QObject>
#include <QMap>
#include "an/constants.h"

namespace SailmiPIM::Util
{
    QMap<QString, QString> GetCategoryNameMap()
	{
		static const QMap<QString, QString> cat2hr
		{
            { AN::CatIM, QObject::tr("Instant messaging") },
            { AN::CatOrganizer, QObject::tr("Organizer") },
            { AN::CatDownloads, QObject::tr("Downloads") },
            { AN::CatPackageManager, QObject::tr("Package manager") },
            { AN::CatMediaPlayer, QObject::tr("Media player") },
            { AN::CatTerminal, QObject::tr("Terminal") },
            { AN::CatNews, QObject::tr("News") },
            { AN::CatGeneric, QObject::tr("Generic") }
		};
		return cat2hr;
	}

	QStringList GetKnownEventTypes(const QString& category)
	{
		static const QMap<QString, QStringList> cat2types
		{
			{
                AN::CatIM,
				{
                    AN::TypeIMAttention,
                    AN::TypeIMIncFile,
                    AN::TypeIMIncMsg,
                    AN::TypeIMMUCHighlight,
                    AN::TypeIMMUCInvite,
                    AN::TypeIMMUCMsg,
                    AN::TypeIMStatusChange,
                    AN::TypeIMSubscrGrant,
                    AN::TypeIMSubscrRequest,
                    AN::TypeIMSubscrRevoke,
                    AN::TypeIMSubscrSub,
                    AN::TypeIMSubscrUnsub,
                    AN::TypeIMEventTuneChange,
                    AN::TypeIMEventMoodChange,
                    AN::TypeIMEventActivityChange,
                    AN::TypeIMEventLocationChange
				}
			},
			{
                AN::CatOrganizer,
				{
                    AN::TypeOrganizerEventDue
				}
			},
			{
                AN::CatDownloads,
				{
                    AN::TypeDownloadError,
                    AN::TypeDownloadFinished
				}
			},
			{
                AN::CatPackageManager,
				{
                    AN::TypePackageUpdated
				}
			},
			{
                AN::CatMediaPlayer,
				{
                    AN::TypeMediaPlaybackStatus
				}
			},
			{
                AN::CatTerminal,
				{
                    AN::TypeTerminalActivity,
                    AN::TypeTerminalInactivity,
                    AN::TypeTerminalBell
				}
			},
			{
                AN::CatNews,
				{
                    AN::TypeNewsSourceUpdated,
                    AN::TypeNewsSourceBroken
				}
			},
			{
                AN::CatGeneric,
				{
                    AN::TypeGeneric
				}
			}
		};
		return cat2types.value(category);
	}

	QString GetCategoryName(const QString& category)
	{
		return GetCategoryNameMap().value(category, category);
	}

	QString GetTypeName(const QString& type)
	{
		static const QMap<QString, QString> type2hr
		{
            { AN::TypeIMAttention, QObject::tr("Attention request") },
            { AN::TypeIMIncFile, QObject::tr("Incoming file transfer request") },
            { AN::TypeIMIncMsg, QObject::tr("Incoming chat message") },
            { AN::TypeIMMUCHighlight, QObject::tr("MUC highlight") },
            { AN::TypeIMMUCInvite, QObject::tr("MUC invitation") },
            { AN::TypeIMMUCMsg, QObject::tr("General MUC message") },
            { AN::TypeIMStatusChange, QObject::tr("Contact status change") },
            { AN::TypeIMSubscrGrant, QObject::tr("Authorization granted") },
            { AN::TypeIMSubscrRevoke, QObject::tr("Authorization revoked") },
            { AN::TypeIMSubscrRequest, QObject::tr("Authorization requested") },
            { AN::TypeIMSubscrSub, QObject::tr("Contact subscribed") },
            { AN::TypeIMSubscrUnsub, QObject::tr("Contact unsubscribed") },
            { AN::TypeIMEventTuneChange, QObject::tr("Contact's tune changed") },
            { AN::TypeIMEventMoodChange, QObject::tr("Contact's mood changed") },
            { AN::TypeIMEventActivityChange, QObject::tr("Contact's activity changed") },
            { AN::TypeIMEventLocationChange, QObject::tr("Contact's location changed") },

            { AN::TypeOrganizerEventDue, QObject::tr("Event is due") },

            { AN::TypeDownloadError, QObject::tr("Download error") },
            { AN::TypeDownloadFinished, QObject::tr("Download finished") },

            { AN::TypePackageUpdated, QObject::tr("Package updated") },

            { AN::TypeMediaPlaybackStatus, QObject::tr("Media playback status changed") },

            { AN::TypeTerminalBell, QObject::tr("Bell in a terminal") },
            { AN::TypeTerminalActivity, QObject::tr("Activity in a terminal") },
            { AN::TypeTerminalInactivity, QObject::tr("Inactivity in a terminal") },

            { AN::TypeNewsSourceUpdated, QObject::tr("News source got updated") },
            { AN::TypeNewsSourceBroken, QObject::tr("News source is detected to be broken") },

            { AN::TypeGeneric, QObject::tr("Generic") }
		};
		return type2hr.value(type, type);
	}
}
